#include "base/assert.hpp"
#include "event/loop.hpp"
#include "network/buffered_fd.hpp"

#include <memory>
#include <unistd.h>

using namespace ibox::event;
using namespace ibox::network;

int main() {
    auto loop = Loop();

    // 创建标准输入 BufferedFd
    auto stdin = std::make_unique<BufferedFd>(loop.ptr());
    Fd stdin_fd{STDIN_FILENO};
    stdin->initialize(stdin_fd, BufferedFd::ReadOnly);

    // 创建标准输出 BufferedFd
    auto stdout = std::make_unique<BufferedFd>(loop.ptr());
    Fd stdout_fd{STDOUT_FILENO};
    stdout->initialize(stdout_fd, BufferedFd::WriteOnly);

    // 将stdin收到的数据转发给stdout
    stdin->bind(stdout.get());

    stdout->enable();
    stdin->enable();

    loop.run();
}
